<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "good".
 *
 * @property int $id
 * @property string $name
 * @property string $price
 * @property int $stock
 * @property string $path
 * @property string $status
 */
class Dev_goods extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'good';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['price'], 'number'],
            [['stock'], 'integer'],
            [['name'], 'string', 'max' => 20,'min'=>5],
            [['path'], 'string', 'max' => 100],
            [['status'], 'string', 'max' => 5],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'price' => 'Price',
            'stock' => 'Stock',
            'path' => 'Path',
            'status' => 'Status',
        ];
    }

    public function add(){
    return $this->save();
    
       }

  public function del($id){
    $customer = Dev_goods::findOne($id);
$customer->delete();

    
       }
       public function saves($id){
   $customer = Dev_goods::findOne($id);
$customer->name = '已修改';
$customer->save();  // 等同于 $customer->update();

    
       }
}
    
